package io.yuncheng.modules.sys.controller;

import java.util.Arrays;
import java.util.Map;

import io.yuncheng.common.validator.ValidatorUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.yuncheng.modules.sys.entity.SubAppWarnLogEntity;
import io.yuncheng.modules.sys.service.SubAppWarnLogService;
import io.yuncheng.common.utils.PageUtils;
import io.yuncheng.common.utils.R;



/**
 * 智能体告警记录
 *
 * @author Mark
 * @email 15721509625@163.com
 * @date 2020-10-08 17:23:02
 */
@RestController
@Api(tags = "告警日志查询")
@RequestMapping("sys/subappwarnlog")
public class SubAppWarnLogController {
    @Autowired
    private SubAppWarnLogService subAppWarnLogService;

    /**
     * 列表
     */
    @PostMapping("/list")
    @ApiOperation("列表-筛选了权限的列表")
    @RequiresPermissions("sys:subappwarnlog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = subAppWarnLogService.queryPageBuildParam(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @RequiresPermissions("sys:subappwarnlog:info")
    public R info(@PathVariable("id") Long id){
        SubAppWarnLogEntity subAppWarnLog = subAppWarnLogService.getById(id);

        return R.ok().put("subAppWarnLog", subAppWarnLog);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @RequiresPermissions("sys:subappwarnlog:save")
    public R save(@RequestBody SubAppWarnLogEntity subAppWarnLog){
        subAppWarnLogService.save(subAppWarnLog);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/update")
    @RequiresPermissions("sys:subappwarnlog:update")
    public R update(@RequestBody SubAppWarnLogEntity subAppWarnLog){
        ValidatorUtils.validateEntity(subAppWarnLog);
        subAppWarnLogService.updateById(subAppWarnLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    @RequiresPermissions("sys:subappwarnlog:delete")
    public R delete(@RequestBody Long[] ids){
        subAppWarnLogService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
